package intopo.game.impl.givetake;

import intopo.game.Strategy;

import cern.jet.random.engine.RandomEngine;

/**
 * A class that represents the common behaviour of a strategy in the
 * Give-Take game.
 *
 * <p>Give-Take is an iterated 2-player game with state. Players take turns
 * sharing an indivisible resource. A player with the resource can give it
 * to its partner, and the player without it can take it back from the
 * partner.
 *
 * @author <a href="mailto:plsm@ua.pt">Pedro Lopes da Silva Mariano</a>
 *
 * @version 2.0
 */
abstract public class GiveTakeStrategy
	implements
		Strategy<GiveTakeStrategy>,
		Cloneable
{
	/**
	 * Sole constructor.
	 */
	protected GiveTakeStrategy ()
	{
	}

	/**
	 * Returns {@code true} if this strategy is going to play the
	 * <i>give</i> action.
	 *
	 * @param history The history of the game so far.
	 * @param index The strategy position either 0 or 1.
	 */
	abstract public boolean give (GiveTakeHistory history, int index);

	/**
	 * Returns {@code true} if this strategy is going to play the
	 * <i>take</i> action.
	 *
	 * @param history The history of the game so far.
	 * @param index The strategy position either 0 or 1.
	 */
	abstract public boolean take (GiveTakeHistory history, int index);
	
	/**
	 * Returns the average number of iterations this strategy keeps the resource before giving it.
	 */
	abstract public int averageGive ();
	
	/**
	 * Returns the average number of iterations this strategy stays without the resource before taking it.
	 */
	abstract public int averageTake ();
	
	abstract public GiveTakeStrategy clone ();
}
